﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;

namespace EuroManager.Domain.Simulator.Tactics
{
    public struct PitchNode
    {
        private int x;
        private int y;

        public PitchNode(int x, int y)
        {
            Contract.Requires(0 <= x && x < PlayerTactics.NodesX);
            Contract.Requires(0 <= y && y < PlayerTactics.NodesY);

            this.x = x;
            this.y = y;
        }

        public int X
        {
            get { return x; }
        }

        public int Y
        {
            get { return y; }
        }

        public static bool operator ==(PitchNode n1, PitchNode n2)
        {
            return n1.Equals(n2);
        }

        public static bool operator !=(PitchNode n1, PitchNode n2)
        {
            return !n1.Equals(n2);
        }

        public override bool Equals(object obj)
        {
            if (obj is PitchNode)
            {
                PitchNode other = (PitchNode)obj;
                return x == other.x && y == other.y;
            }
            else
            {
                return false;
            }
        }

        public override int GetHashCode()
        {
            return x.GetHashCode() + y.GetHashCode();
        }
    }
}
